#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>


int main()

{
     umask(0);
     int fd=open("log.txt",O_CREAT | O_WRONLY | O_APPEND, 0666);
     if(fd<0)
     {
           perror("open");
     }
     printf("fd : %d\n",fd);
     const char * msg = "hello CMJ DCM!\n";
    int cnt=5;
    while(cnt)
    {
       write(fd,msg,strlen(msg));
        cnt--;
    }
        close(fd);
return 0;
}
